//
//  QBWTRightList.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/18.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "QBWTRightList.h"

@interface QBWTRightList ()

@property (strong, nonatomic) NSMutableArray *dataListArr;

@property (strong, nonatomic) SYNoLabel *noLab;

@end

@implementation QBWTRightList

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerClass:[QBWTRCell class] forCellReuseIdentifier:@"QBWTRCell"];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _noLab = [[SYNoLabel alloc] initWithNameStr:@"" contView:self.view];
}

- (void)requestDataListArr:(NSMutableArray *)dataListArr {
    self.dataListArr = dataListArr;
    if (dataListArr.count == 0) {
        self.tableView.hidden = YES;
        _noLab.hidden = NO;
    } else {
        _noLab.hidden = YES;
        self.tableView.hidden = NO;
        [self.tableView reloadData];
    }
    
}


#pragma mark - Table view data source


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataListArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 121*fh+20;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    QBWTRCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QBWTRCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[QBWTRCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"QBWTRCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor whiteColor];
    
    SYWenTiDetailsModel *details = self.dataListArr[indexPath.row];
    
    [cell.leftImageView sd_setImageWithURL:[NSURL URLWithString:details.cover]];
    [cell.headerImageView sd_setImageWithURL:[NSURL URLWithString:details.headImg]];
    cell.nameLabel.text = details.name;
    cell.dateLabel.text = details.createDate;
    
    return cell;
}

// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}



// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}



// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}



// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}

@end
